﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using HZ.Supervise.Model;
namespace HZ.Supervise.Web.Master
{
    public partial class MasterPageIframe : System.Web.UI.Page
    {
        public string strURL = "";
        string strhid = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ViewState["query"] = URLUtil.GetSuperviseQueryFromURL(Request);
                bangdingHostial();
                strURL = "../Secondphase/ReportHospital/ReportOfHospitalFirstLevel.aspx";
            }
            else
            { 
                strURL = "../Secondphase/ReportHospital/Blank.aspx";
            }

        }

        protected void gvwselect_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string sessionid = Guid.NewGuid().ToString();
                SuperviseQuery query = new SuperviseQuery();
                query.HospitalName = e.Row.Cells[0].Text.Trim();
                Session[sessionid] = query;
                e.Row.Cells[0].Text = "<a  style=\"cursor:hand\" onclick=\"seturl('" + sessionid + "')\">" + e.Row.Cells[0].Text + "</a>";
 
            }
        }

        /// <summary>
        /// 绑定医院
        /// </summary>
        private void bangdingHostial()
        {
            HZ.Supervise.IBLL.IBLL_PreWarning pre = HZ.Supervise.BLLFactory.IBLL_PreWarning();
            string _HospitalID = txtname.Text.Trim();
            if (_HospitalID.Equals(""))
            {
                _HospitalID = "所有医院";
            }
            int totalrecord = 0;
            DataTable dt = pre.GetHospitalName(_HospitalID, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, out totalrecord);
            AspNetPager1.RecordCount = totalrecord;
            gvwselect.DataSource = dt;
            gvwselect.DataBind();
        }

         
        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnQuery_Click(object sender, EventArgs e)
        {
            this.AspNetPager1.CurrentPageIndex = 1;
            bangdingHostial();
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            bangdingHostial();
        }
 
    }
}
